package nl.stroep.classbuilder.cb 
{
	import nl.stroep.classbuilder.cb.interfaces.ICbWrapper;
	import nl.stroep.classbuilder.definitions.Chars;
	
	/**
	 * Defines a getter definition, which is a method that can be read like a property.
	 * @author Mark Knol - Stroep.nl - 2010 (c)
	 */
	public class CbGetMethod implements ICbWrapper
	{
		private var _name:String;
		private var _type:String;
		private var _defaultValue:String;
		
		private var cbFunction:CbMethod;
		
		public function CbGetMethod(name:String, type:String = "void", defaultValue:String = null ) 
		{
			cbFunction = new CbMethod(name);
			
			cbFunction.isGetter = true;
			
			this._name = name;
			this._type = type;
			this._defaultValue = defaultValue;
		}
		
		public function toString():String
		{
			cbFunction.name = this._name;
			cbFunction.type = this._type;
			cbFunction.defaultValue =  "return _" + this._name + Chars.SEMICOLON + (this._defaultValue ? Chars.NEWLINE + this._defaultValue : Chars.EMPTY);
			
			return cbFunction.toString()
		}
		
		public function get name():String { return _name; }
		
		public function set name(value:String):void 
		{
			_name = value;
		}
		
		public function get type():String { return _type; }
		
		public function set type(value:String):void 
		{
			_type = value;
		}
		
		public function get defaultValue():String { return _defaultValue; }
		
		public function set defaultValue(value:String):void 
		{
			_defaultValue = value;
		}
		
	}

}